

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Code Reviews with Phabricator &#8212; LLVM 9 documentation</title>
    <link rel="stylesheet" href="_static/llvm-theme.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/doctools.js"></script>
    <script src="_static/language_data.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="LLVM Testing Infrastructure Guide" href="TestingGuide.html" />
    <link rel="prev" title="}" href="MarkdownQuickstartTemplate.html" />
<style type="text/css">
  table.right { float: right; margin-left: 20px; }
  table.right td { border: 1px solid #ccc; }
</style>

  </head><body>
<div class="logo">
  <a href="index.html">
    <img src="_static/logo.png"
         alt="LLVM Logo" width="250" height="88"/></a>
</div>

    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="TestingGuide.html" title="LLVM Testing Infrastructure Guide"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="MarkdownQuickstartTemplate.html" title="}"
             accesskey="P">previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="index.html">Documentation</a>&raquo;</li>

        <li class="nav-item nav-item-this"><a href="">Code Reviews with Phabricator</a></li> 
      </ul>
    </div>


    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <div class="section" id="code-reviews-with-phabricator">
<span id="phabricator-reviews"></span><h1>Code Reviews with Phabricator<a class="headerlink" href="#code-reviews-with-phabricator" title="Permalink to this headline">¶</a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#sign-up" id="id2">Sign up</a></p></li>
<li><p><a class="reference internal" href="#requesting-a-review-via-the-command-line" id="id3">Requesting a review via the command line</a></p></li>
<li><p><a class="reference internal" href="#requesting-a-review-via-the-web-interface" id="id4">Requesting a review via the web interface</a></p></li>
<li><p><a class="reference internal" href="#finding-potential-reviewers" id="id5">Finding potential reviewers</a></p></li>
<li><p><a class="reference internal" href="#reviewing-code-with-phabricator" id="id6">Reviewing code with Phabricator</a></p></li>
<li><p><a class="reference internal" href="#committing-a-change" id="id7">Committing a change</a></p>
<ul>
<li><p><a class="reference internal" href="#committing-someone-s-change-from-phabricator" id="id8">Committing someone’s change from Phabricator</a></p></li>
<li><p><a class="reference internal" href="#subversion-and-arcanist-deprecated" id="id9">Subversion and Arcanist (deprecated)</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#abandoning-a-change" id="id10">Abandoning a change</a></p></li>
<li><p><a class="reference internal" href="#status" id="id11">Status</a></p></li>
</ul>
</div>
<p>If you prefer to use a web user interface for code reviews, you can now submit
your patches for Clang and LLVM at <a class="reference external" href="https://reviews.llvm.org">LLVM’s Phabricator</a> instance.</p>
<p>While Phabricator is a useful tool for some, the relevant -commits mailing list
is the system of record for all LLVM code review. The mailing list should be
added as a subscriber on all reviews, and Phabricator users should be prepared
to respond to free-form comments in mail sent to the commits list.</p>
<div class="section" id="sign-up">
<h2><a class="toc-backref" href="#id2">Sign up</a><a class="headerlink" href="#sign-up" title="Permalink to this headline">¶</a></h2>
<p>To get started with Phabricator, navigate to <a class="reference external" href="https://reviews.llvm.org">https://reviews.llvm.org</a> and
click the power icon in the top right. You can register with a GitHub account,
a Google account, or you can create your own profile.</p>
<p>Make <em>sure</em> that the email address registered with Phabricator is subscribed
to the relevant -commits mailing list. If you are not subscribed to the commit
list, all mail sent by Phabricator on your behalf will be held for moderation.</p>
<p>Note that if you use your Subversion user name as Phabricator user name,
Phabricator will automatically connect your submits to your Phabricator user in
the <a class="reference external" href="https://reviews.llvm.org/diffusion/">Code Repository Browser</a>.</p>
</div>
<div class="section" id="requesting-a-review-via-the-command-line">
<h2><a class="toc-backref" href="#id3">Requesting a review via the command line</a><a class="headerlink" href="#requesting-a-review-via-the-command-line" title="Permalink to this headline">¶</a></h2>
<p>Phabricator has a tool called <em>Arcanist</em> to upload patches from
the command line. To get you set up, follow the
<a class="reference external" href="https://secure.phabricator.com/book/phabricator/article/arcanist_quick_start/">Arcanist Quick Start</a> instructions.</p>
<p>You can learn more about how to use arc to interact with
Phabricator in the <a class="reference external" href="https://secure.phabricator.com/book/phabricator/article/arcanist/">Arcanist User Guide</a>.</p>
</div>
<div class="section" id="requesting-a-review-via-the-web-interface">
<span id="phabricator-request-review-web"></span><h2><a class="toc-backref" href="#id4">Requesting a review via the web interface</a><a class="headerlink" href="#requesting-a-review-via-the-web-interface" title="Permalink to this headline">¶</a></h2>
<p>The tool to create and review patches in Phabricator is called
<em>Differential</em>.</p>
<p>Note that you can upload patches created through various diff tools,
including git and svn. To make reviews easier, please always include
<strong>as much context as possible</strong> with your diff! Don’t worry, Phabricator
will automatically send a diff with a smaller context in the review
email, but having the full file in the web interface will help the
reviewer understand your code.</p>
<p>To get a full diff, use one of the following commands (or just use Arcanist
to upload your patch):</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">show</span> <span class="pre">HEAD</span> <span class="pre">-U999999</span> <span class="pre">&gt;</span> <span class="pre">mypatch.patch</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">format-patch</span> <span class="pre">-U999999</span> <span class="pre">&#64;{u}</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">svn</span> <span class="pre">diff</span> <span class="pre">--diff-cmd=diff</span> <span class="pre">-x</span> <span class="pre">-U999999</span></code></p></li>
</ul>
<p>To upload a new patch:</p>
<ul class="simple">
<li><p>Click <em>Differential</em>.</p></li>
<li><p>Click <em>+ Create Diff</em>.</p></li>
<li><p>Paste the text diff or browse to the patch file. Click <em>Create Diff</em>.</p></li>
<li><p>Leave this first Repository field blank. (We’ll fill in the Repository
later, when sending the review.)</p></li>
<li><p>Leave the drop down on <em>Create a new Revision…</em> and click <em>Continue</em>.</p></li>
<li><p>Enter a descriptive title and summary.  The title and summary are usually
in the form of a <a class="reference internal" href="DeveloperPolicy.html#commit-messages"><span class="std std-ref">commit message</span></a>.</p></li>
<li><p>Add reviewers (see below for advice). (If you set the Repository field
correctly, llvm-commits or cfe-commits will be subscribed automatically;
otherwise, you will have to manually subscribe them.)</p></li>
<li><p>In the Repository field, enter the name of the project (LLVM, Clang,
etc.) to which the review should be sent.</p></li>
<li><p>Click <em>Save</em>.</p></li>
</ul>
<p>To submit an updated patch:</p>
<ul class="simple">
<li><p>Click <em>Differential</em>.</p></li>
<li><p>Click <em>+ Create Diff</em>.</p></li>
<li><p>Paste the updated diff or browse to the updated patch file. Click <em>Create Diff</em>.</p></li>
<li><p>Select the review you want to from the <em>Attach To</em> dropdown and click
<em>Continue</em>.</p></li>
<li><p>Leave the Repository field blank. (We previously filled out the Repository
for the review request.)</p></li>
<li><p>Add comments about the changes in the new diff. Click <em>Save</em>.</p></li>
</ul>
<p>Choosing reviewers: You typically pick one or two people as initial reviewers.
This choice is not crucial, because you are merely suggesting and not requiring
them to participate. Many people will see the email notification on cfe-commits
or llvm-commits, and if the subject line suggests the patch is something they
should look at, they will.</p>
</div>
<div class="section" id="finding-potential-reviewers">
<span id="id1"></span><h2><a class="toc-backref" href="#id5">Finding potential reviewers</a><a class="headerlink" href="#finding-potential-reviewers" title="Permalink to this headline">¶</a></h2>
<p>Here are a couple of ways to pick the initial reviewer(s):</p>
<ul class="simple">
<li><p>Use <code class="docutils literal notranslate"><span class="pre">svn</span> <span class="pre">blame</span></code> and the commit log to find names of people who have
recently modified the same area of code that you are modifying.</p></li>
<li><p>Look in CODE_OWNERS.TXT to see who might be responsible for that area.</p></li>
<li><p>If you’ve discussed the change on a dev list, the people who participated
might be appropriate reviewers.</p></li>
</ul>
<p>Even if you think the code owner is the busiest person in the world, it’s still
okay to put them as a reviewer. Being the code owner means they have accepted
responsibility for making sure the review happens.</p>
</div>
<div class="section" id="reviewing-code-with-phabricator">
<h2><a class="toc-backref" href="#id6">Reviewing code with Phabricator</a><a class="headerlink" href="#reviewing-code-with-phabricator" title="Permalink to this headline">¶</a></h2>
<p>Phabricator allows you to add inline comments as well as overall comments
to a revision. To add an inline comment, select the lines of code you want
to comment on by clicking and dragging the line numbers in the diff pane.
When you have added all your comments, scroll to the bottom of the page and
click the Submit button.</p>
<p>You can add overall comments in the text box at the bottom of the page.
When you’re done, click the Submit button.</p>
<p>Phabricator has many useful features, for example allowing you to select
diffs between different versions of the patch as it was reviewed in the
<em>Revision Update History</em>. Most features are self descriptive - explore, and
if you have a question, drop by on #llvm in IRC to get help.</p>
<p>Note that as e-mail is the system of reference for code reviews, and some
people prefer it over a web interface, we do not generate automated mail
when a review changes state, for example by clicking “Accept Revision” in
the web interface. Thus, please type LGTM into the comment box to accept
a change from Phabricator.</p>
</div>
<div class="section" id="committing-a-change">
<h2><a class="toc-backref" href="#id7">Committing a change</a><a class="headerlink" href="#committing-a-change" title="Permalink to this headline">¶</a></h2>
<p>Once a patch has been reviewed and approved on Phabricator it can then be
committed to trunk. If you do not have commit access, someone has to
commit the change for you (with attribution). It is sufficient to add
a comment to the approved review indicating you cannot commit the patch
yourself. If you have commit access, there are multiple workflows to commit the
change. Whichever method you follow it is recommended that your commit message
ends with the line:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Differential</span> <span class="n">Revision</span><span class="p">:</span> <span class="o">&lt;</span><span class="n">URL</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>where <code class="docutils literal notranslate"><span class="pre">&lt;URL&gt;</span></code> is the URL for the code review, starting with
<code class="docutils literal notranslate"><span class="pre">https://reviews.llvm.org/</span></code>.</p>
<p>This allows people reading the version history to see the review for
context. This also allows Phabricator to detect the commit, close the
review, and add a link from the review to the commit.</p>
<p>Note that if you use the Arcanist tool the <code class="docutils literal notranslate"><span class="pre">Differential</span> <span class="pre">Revision</span></code> line will
be added automatically. If you don’t want to use Arcanist, you can add the
<code class="docutils literal notranslate"><span class="pre">Differential</span> <span class="pre">Revision</span></code> line (as the last line) to the commit message
yourself.</p>
<p>Using the Arcanist tool can simplify the process of committing reviewed code as
it will retrieve reviewers, the <code class="docutils literal notranslate"><span class="pre">Differential</span> <span class="pre">Revision</span></code>, etc from the review
and place it in the commit message. You may also commit an accepted change
directly using <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">llvm</span> <span class="pre">push</span></code>, per the section in the <a class="reference internal" href="GettingStarted.html#commit-from-git"><span class="std std-ref">getting started
guide</span></a>.</p>
<p>Note that if you commit the change without using Arcanist and forget to add the
<code class="docutils literal notranslate"><span class="pre">Differential</span> <span class="pre">Revision</span></code> line to your commit message then it is recommended
that you close the review manually. In the web UI, under “Leap Into Action” put
the SVN revision number in the Comment, set the Action to “Close Revision” and
click Submit.  Note the review must have been Accepted first.</p>
<div class="section" id="committing-someone-s-change-from-phabricator">
<h3><a class="toc-backref" href="#id8">Committing someone’s change from Phabricator</a><a class="headerlink" href="#committing-someone-s-change-from-phabricator" title="Permalink to this headline">¶</a></h3>
<p>On a clean Git repository on an up to date <code class="docutils literal notranslate"><span class="pre">master</span></code> branch run the
following (where <code class="docutils literal notranslate"><span class="pre">&lt;Revision&gt;</span></code> is the Phabricator review number):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">arc</span> <span class="n">patch</span> <span class="n">D</span><span class="o">&lt;</span><span class="n">Revision</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>This will create a new branch called <code class="docutils literal notranslate"><span class="pre">arcpatch-D&lt;Revision&gt;</span></code> based on the
current <code class="docutils literal notranslate"><span class="pre">master</span></code> and will create a commit corresponding to <code class="docutils literal notranslate"><span class="pre">D&lt;Revision&gt;</span></code> with a
commit message derived from information in the Phabricator review.</p>
<p>Check you are happy with the commit message and amend it if necessary. Then,
make sure the commit is up-to-date, and commit it. This can be done by running
the following:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>git pull --rebase origin master
git show # Ensure the patch looks correct.
ninja check-$whatever # Rerun the appropriate tests if needed.
git llvm push
</pre></div>
</div>
</div>
<div class="section" id="subversion-and-arcanist-deprecated">
<h3><a class="toc-backref" href="#id9">Subversion and Arcanist (deprecated)</a><a class="headerlink" href="#subversion-and-arcanist-deprecated" title="Permalink to this headline">¶</a></h3>
<p>To download a change from Phabricator and commit it with subversion, you should
first make sure you have a clean working directory. Then run the following
(where <code class="docutils literal notranslate"><span class="pre">&lt;Revision&gt;</span></code> is the Phabricator review number):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">arc</span> <span class="n">patch</span> <span class="n">D</span><span class="o">&lt;</span><span class="n">Revision</span><span class="o">&gt;</span>
<span class="n">arc</span> <span class="n">commit</span> <span class="o">--</span><span class="n">revision</span> <span class="n">D</span><span class="o">&lt;</span><span class="n">Revision</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>The first command will take the latest version of the reviewed patch and apply
it to the working copy. The second command will commit this revision to trunk.</p>
</div>
</div>
<div class="section" id="abandoning-a-change">
<h2><a class="toc-backref" href="#id10">Abandoning a change</a><a class="headerlink" href="#abandoning-a-change" title="Permalink to this headline">¶</a></h2>
<p>If you decide you should not commit the patch, you should explicitly abandon
the review so that reviewers don’t think it is still open. In the web UI,
scroll to the bottom of the page where normally you would enter an overall
comment. In the drop-down Action list, which defaults to “Comment,” you should
select “Abandon Revision” and then enter a comment explaining why. Click the
Submit button to finish closing the review.</p>
</div>
<div class="section" id="status">
<h2><a class="toc-backref" href="#id11">Status</a><a class="headerlink" href="#status" title="Permalink to this headline">¶</a></h2>
<p>Please let us know whether you like it and what could be improved! We’re still
working on setting up a bug tracker, but you can email klimek-at-google-dot-com
and chandlerc-at-gmail-dot-com and CC the llvm-dev mailing list with questions
until then. We also could use help implementing improvements. This sadly is
really painful and hard because the Phabricator codebase is in PHP and not as
testable as you might like. However, we’ve put exactly what we’re deploying up
on an <a class="reference external" href="https://github.com/r4nt/llvm-reviews/">llvm-reviews GitHub project</a> where folks can hack on it and post pull
requests. We’re looking into what the right long-term hosting for this is, but
note that it is a derivative of an existing open source project, and so not
trivially a good fit for an official LLVM project.</p>
</div>
</div>


            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="TestingGuide.html" title="LLVM Testing Infrastructure Guide"
             >next</a> |</li>
        <li class="right" >
          <a href="MarkdownQuickstartTemplate.html" title="}"
             >previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="index.html">Documentation</a>&raquo;</li>

        <li class="nav-item nav-item-this"><a href="">Code Reviews with Phabricator</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2003-2020, LLVM Project.
      Last updated on 2020-09-20.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
    </div>
  </body>
</html>